#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
string s;
int n, x;
string mp[110];
int mp1[110];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s;
		cin >> x;
		mp[x] = s;
		mp1[x] = i;
	}
	for (int i = 1; i <= n; i++) {
		bool flag = 0;
		for (int j = i + 1; j <= n; j++) {
			if (mp[i] == mp[j]) {
				flag = 1;
				break;
			}
		}
		if (!flag) {
			cout << mp1[i] << endl;
		}
	}
	return 0;
}
